package com.letoy.edu.controller;

import com.letoy.edu.entity.StudentInfo;
import com.letoy.edu.service.StudentInfoService;
import com.letoy.edu.vo.Student;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Api(value = "学生信息管理", tags = "学生信息API")
public class StudentInfoController {

    @Autowired
    StudentInfoService studentInfoService;

    @PostMapping("/student/findAllStudent")
    @ApiOperation(value = "学生信息表查询所有", notes = "学生信息表查询所有")
    @ApiImplicitParam(value = "", name = "Authorization", paramType = "header", dataType = "String", required = true)
    private Map<String, Object> findAllStudent() {
        return studentInfoService.findAllStudent();
    }

    @PostMapping("/student/findStudentByNumber")
    @ApiOperation(value = "学生信息表根据学号查询", notes = "学生信息表根据学号查询")
    @ApiImplicitParam(value = "", name = "Authorization", paramType = "header", dataType = "String", required = true)
    private Map<String, Object> findStudentByNumber(int number) {
        return studentInfoService.findStudentByNumber(number);
    }

    @PostMapping("/student/insertStudent")
    @ApiOperation(value = "新增学生信息", notes = "新增学生信息")
    @ApiImplicitParam(value = "", name = "Authorization", paramType = "header", dataType = "String", required = true)
    private Map<String, Object> insertStudent(StudentInfo studentInfo) {
        return studentInfoService.insertStudent(studentInfo);
    }

    @PostMapping("/student/updateStudent")
    @ApiOperation(value = "更新学生信息", notes = "更新学生信息")
    @ApiImplicitParam(value = "", name = "Authorization", paramType = "header", dataType = "String", required = true)
    private Map<String, Object> updateStudent(StudentInfo studentInfo) {
        return studentInfoService.updateStudent(studentInfo);
    }

    @PostMapping("/student/deleteStudent")
    @ApiOperation(value = "删除学生信息", notes = "删除学生信息")
    @ApiImplicitParam(value = "", name = "Authorization", paramType = "header", dataType = "String", required = true)
    private Map<String, Object> deleteStudent(int number) {
        return studentInfoService.deleteStudent(number);
    }
}
